import { Modal } from '@arco-design/web-vue';
import { defineComponent, unref } from 'vue';
import { basicProps } from '../props';
import { useAttrs } from '@/hooks/core/useAttrs';
import { extendSlots } from '@/utils/helper/tsxHelper';

export default defineComponent({
  name: 'ModalEle',
  inheritAttrs: false,
  props: basicProps,
  emits: ['cancel'],
  setup(props, { slots, emit }) {
    const attrs = useAttrs();

    return () => {
      const propsData = { ...unref(attrs), ...props } as Recordable;
      const onCancel = function () {
        emit('cancel');
      };
      return (
        <Modal {...propsData} onCancel={onCancel}>
          {extendSlots(slots)}
        </Modal>
      );
    };
  },
});
